<script type="text/javascript">
    $(document).ready(function() {
        //------- Google Maps ---------//
		  
        // Creating a LatLng object containing the coordinate for the center of the map
        var latlng = new google.maps.LatLng(-33.92367,18.427162);
	  
        // Creating an object literal containing the properties we want to pass to the map  
        var options = {  
            zoom: 13, // This number can be set to define the initial zoom level of the map
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP // This value can be set to define the map type ROADMAP/SATELLITE/HYBRID/TERRAIN
        };  
        // Calling the constructor, thereby initializing the map  
        var map = new google.maps.Map(document.getElementById('doctors-search-google-map'), options);  
	
        // Define Marker properties
        var image = new google.maps.MarkerImage('/images/marker_greenB.png',
        // This marker is 300 pixels wide by 180 pixels tall.
        new google.maps.Size(300, 180),
        // The origin for this image is 0,0.
        new google.maps.Point(0,0),
        // The anchor for this image is the base of the flagpole at 18,42.
        new google.maps.Point(18, 42)
    );
        
<?php $i = 0 ?>        
<?php foreach (DoctorLocationTable::getInstance()->findAll() as $doctorLocation): ?>
    <?php if ($doctorLocation->getLatitude() != '' && $doctorLocation->getLongitude() != ''): ?>
        <?php $i++ ?>                            
                    // Add Marker
                    var marker<?php echo $i ?> = new google.maps.Marker({
                        position: new google.maps.LatLng(<?php echo $doctorLocation->getLatitude() . ", " . $doctorLocation->getLongitude() ?>), 
                        map: map,		
                        icon: image // This path is the custom pin to be shown. Remove this line and the proceeding comma to use default pin
                    });	
                        	
                    // Add listener for a click on the pin
                    google.maps.event.addListener(marker<?php echo $i ?>, 'click', function() {  
                        infowindow<?php echo $i ?>.open(map, marker<?php echo $i ?>);  
                    });
                        		
                    // Add information window
                    var infowindow<?php echo $i ?> = new google.maps.InfoWindow({  
                        content: document.getElementById("google-map-profile-<?php echo $doctorLocation->getId() ?>")
                    });       
    <?php endif; ?>
<?php endforeach; ?>	
        // Create information window
        function createInfo(title, content) {
            return '<div class="infowindow"><strong>'+ title +'</strong><br />' + content + '</div>';
        }
    });
</script>

